﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KinectUserManager
{
    public static class KinectScaner
    {
        public static VectorXYZ HipCenter { get; set; }
        public static bool checkDistance(int[,] currDistance,int[,]nextDistance)
        {
            int range = (nextDistance.GetLength(1) * nextDistance.GetLength(0)) / 15;
            int diference = 0;
            for (int y = 0; y < nextDistance.GetLength(1); y++)
            {
                for (int x = 0; x < nextDistance.GetLength(0); x++)
                {
                    //ambas mayor que cero
                    if (currDistance[x, y] > 0 && nextDistance[x, y] > 0)
                    {
                        int amount = nextDistance[x, y] - currDistance[x, y];
                        if (amount < -30 || amount > 30&&nextDistance[x,y]<3000)
                        {
                            diference++;
                        }
                    }
                }
            }
            return diference > range;

        }
        public static int FigureInclination(int currentAngle)
        {
            int angle = 0;
            //VectorXY hipPoint = new VectorXY() { X = (int)(((Math.Abs(HipCenter.Y)) * 150)), Y = (int)((HipCenter.Z) * 100) };
            VectorXY hipPoint = new VectorXY() { X = (int)(((Math.Abs(HipCenter.Y)) * 100)), Y = (int)((HipCenter.Z) * 100) };
            double hipotenusa=Math.Sqrt((hipPoint.X*hipPoint.X)+(hipPoint.Y*hipPoint.Y));
            angle=(int)(((Math.Asin(hipPoint.X / hipotenusa))*180)/Math.PI);
            return currentAngle-angle;
        }
    }
}
